{extend name="default/layout" /}

{block name="content"}
{cms:hooks name="index.before.content" /}
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
    <!-- 内容顶部广告位 -->
    {cms:hooks name="content.top" /}
    <!-- 精品推荐 -->
    <div class="mb-12">
        <!-- 分类标题 -->
        <div class="flex items-center justify-between mb-6">
            <div class="flex items-center space-x-4">
                <h2 class="section-title text-gray-800 text-xl font-semibold">
                    精品推荐
                </h2>
            </div>
        </div>

        <!-- 商品网格 - 响应式布局 -->
        <div class="grid grid-cols-1 md:grid-cols-5 gap-3 md:gap-6">
            {cms:goods limit="10" image="1"}
            <a href="{$goods.url}" class="block h-full group">
                <div
                    class="bg-white rounded-sm overflow-hidden hover:border-gray-300 transition-colors h-full flex flex-row md:flex-col ">
                    <!-- 商品图片 -->
                    <div
                        class="relative bg-gray-100 overflow-hidden w-20 h-20 md:w-full md:h-32 flex-shrink-0 md:aspect-w-2 md:aspect-h-1">
                        <img src=""
                            data-src="{$goods.image}" alt="{$goods.name}"
                            class="w-full h-full object-cover lazy-image rounded md:rounded-t-sm md:rounded-none">
                    </div>

                    <!-- 商品信息 -->
                    <div class="p-3 flex-1 flex flex-col justify-between md:justify-start">
                        <div
                            class="text-sm font-medium text-gray-800 line-clamp-2 leading-tight md:h-10 md:leading-5 flex-1 mb-2">
                            {$goods.name}
                        </div>
                        <div class="flex items-center justify-between md:mt-2">
                            <div class="flex items-center">

                                <span class="text-blue-600 font-bold price-container flex gap-1 items-center">
                                    <span class="text-xs currency-symbol text-blue-500">{:conf('site_currency_symbol')}</span>
                                    <span class="md:text-lg text-base price-number font-semibold">{$goods.price}</span>
                                </span>
                            </div>
                            <div class="flex items-center space-x-1">
                                <span class="text-xs text-gray-400">
                                    热度 <span class="view-count">{$goods.views|format_view_count}</span>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </a>
            {/cms:goods}
        </div>
    </div>

    <!-- 分类商品 -->
    {volist name="categories" id="category"}
    <div class="mb-12">
        <!-- 分类标题 - 响应式布局 -->
        <div class="mb-3 md:mb-6">
            <div class="flex flex-col md:flex-row md:items-center md:justify-between gap-2 md:gap-4">
                <div class="flex flex-col md:flex-row md:items-center gap-2 md:gap-4 flex-1">
                    <a href="{:_url_('goods.category', ['pinyin' => $category.pinyin])}"
                        class="text-lg font-bold text-gray-800 hover:text-blue-500 transition-colors section-title ">
                        {$category.name}
                    </a>
                </div>
                <div>
                    {if $category.children}
                    <div class="flex flex-wrap gap-1.5 md:gap-3">
                        {volist name="category.children" id="child" limit="3,8"}
                        <a href="{:_url_('goods.category', ['pinyin' => $child.pinyin])}"
                            class="text-xs md:text-sm text-gray-600 hover:text-gray-800 transition-colors px-1.5 py-0.5 md:px-0 md:py-0 bg-gray-50 md:bg-transparent rounded-full md:rounded-none">
                            {$child.name}
                        </a>
                        {/volist}
                        {if count($category.children) > 3}
                        <a href="{:_url_('goods.category', ['pinyin' => $category.pinyin])}"
                            class="flex items-center text-xs md:text-sm text-gray-600 hover:text-gray-800 transition-colors">
                            <span>更多 →</span>
                        </a>
                        {/if}
                    </div>
                    {/if}

                </div>
            </div>
        </div>

        <!-- 商品网格 - 响应式布局 -->
        {if $category.goods}
        <div class="grid grid-cols-1 md:grid-cols-5 gap-3 md:gap-6">
            {volist name="category.goods" id="goods"}
            <a href="{$goods.url}" class="block h-full group">
                <div
                    class="bg-white rounded-sm overflow-hidden hover:border-gray-300 transition-colors h-full flex flex-row md:flex-col ">
                    <!-- 商品图片 -->
                    <div
                        class="relative bg-gray-100 overflow-hidden w-20 h-20 md:w-full md:h-32 flex-shrink-0 md:aspect-w-2 md:aspect-h-1">
                        <img src=""
                            data-src="{$goods.image}" alt="{$goods.name}"
                            class="absolute inset-0 w-full h-full object-cover lazy-image rounded md:rounded-t-sm md:rounded-none">

                    </div>

                    <!-- 商品信息 -->
                    <div class="p-3 flex-1 flex flex-col justify-between md:justify-start">
                        <div
                            class="text-sm font-medium text-gray-800 line-clamp-2 leading-tight md:h-10 md:leading-5 flex-1 mb-2">
                            {$goods.name}
                        </div>
                        <div class="flex items-center justify-between md:mt-2">
                            <div class="flex items-center">
                                <span class="text-blue-600 font-bold price-container flex gap-1 items-center">
                                    <span class="text-xs currency-symbol text-blue-500">{:conf('site_currency_symbol')}</span>
                                    <span class="md:text-lg text-base price-number font-semibold">{$goods.price}</span>
                                </span>
                            </div>
                            <div class="flex items-center space-x-1">
                                <span class="text-xs text-gray-400">
                                    <i class="fas fa-eye mr-1"></i><span class="view-count"
                                        data-count="{$goods.views|default=0}">{$goods.views|default=0|format_view_count}</span>
                                </span>
                            </div>
                        </div>
                    </div>
                </div>
            </a>
            {/volist}
        </div>
        {else}
        <div class="text-center py-12">
            <div class="text-gray-400">
                <i class="fas fa-box-open text-4xl mb-4"></i>
                <p>暂无商品</p>
            </div>
        </div>
        {/if}
    </div>
    {/volist}

    <!-- 如果没有分类 -->
    {if !$categories}
    <div class="text-center py-20">
        <div class="text-gray-400">
            <i class="fas fa-store text-6xl mb-6"></i>
            <h3 class="text-xl font-medium mb-2">商店正在准备中</h3>
            <p>精彩内容即将上线，敬请期待！</p>
        </div>
    </div>
    {/if}

    <!-- 内容底部广告位 -->
    {cms:hooks name="content.bottom" /}

    <!-- 友情链接 -->
    {cms:hooks name="home.before.footer" /}

</div>
{/block}

{block name="js"}
{/block}